﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Galnote.Class
{
	public class ScrollPager : DataPager
	{
		public ScrollPager()
			: base()
		{
			this.DefaultStyleKey = typeof(ScrollPager);
			base.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
		}

		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
		}

		protected override void OnMouseWheel(MouseWheelEventArgs e)
		{
			base.OnMouseWheel(e);
			if (!e.Handled)
			{
				int pageIndex = e.Delta / -120 + PageIndex;
				if (pageIndex >= PageCount)
					PageIndex = PageCount - 1;
				else if (pageIndex < 0)
					PageIndex = 0;
				else
					PageIndex = pageIndex;
			}
		}
	}

	public class PlusConverter : System.Windows.Data.IValueConverter
	{
		#region IValueConverter 成员

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			double v = double.Parse(value.ToString());
			double p = double.Parse(parameter.ToString());
			return System.Convert.ChangeType(v + p, targetType, null);
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			double v = double.Parse(value.ToString());
			double p = double.Parse(parameter.ToString());
			return System.Convert.ChangeType(v - p, targetType, null);
		}

		#endregion
	}
}
